//给打包组件库使用
const path = require('path');
const {VueLoaderPlugin} = require('vue-loader');
module.exports = {
  mode:'production',
  entry:path.resolve(__dirname,'../packages/my-ui/index.ts'),
  output:{
    path:path.resolve(__dirname,'../lib'),
    filename:'index.js',
    libraryTarget:'umd',
    library:'my-ui'
  },
  externals:{
    vue:{root:'Vue',commonjs:'vue',commonjs2:'vue'}
  },
  resolve:{ //解析模块，对应的扩展名有哪些
    extensions:['.ts','.tsx','.js','.vue']
  },
  module:{// loader 三种写法  { }  ""  []
    rules:[
      {test:/\.vue$/,loader:'vue-loader'},
      {test:/\.(ts|js)x?$/,exclude:/node_modules/,loader:'babel-loader'}
    ]
  },
  plugins:[
    new VueLoaderPlugin(),
  ]
}

// 组件库打包格式
// 1.整个打包了umd
// 2.esModule
// 3.组件的按需加载，需要把每个文件单独打包